<#include "/common/head.ftl">

<@showTitle title="${i18n.getMessage('student')} > ${i18n.getMessage('create_one')}">
</@showTitle>

<div id="error" style="display:none"></div>

<form action="student/addStudent.sgt" onsubmit="submitFormValidation(this); return false;" validator="student/validateStudent.sgt" onreset="$('error').hide()">
	<div class="flover">
		<h4><@required/>${i18n.getMessage('surveyInfo')}</h4>
		<p>${i18n.getMessage('surveyInfo.text')}</p>
		<ul>
		<#list surveyInfos as surveyInfo>
			<li><input type="checkbox" name="surveyInfos" value="${(surveyInfo.id)!}" /> ${(surveyInfo.description)!}</li>
		</#list>
		</ul>
	</div>
	<table id="dataTable" align="center" cellspacing="5" cellpadding="0" style="margin-left: 100px;">
		<tr>
			<td class="name"><@required/>${i18n.getMessage('firstName')}:</td>
			<td><input type="text" name="firstName" style="width:200px"/></td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('lastName')}:</td>
			<td><input type="text" name="lastName" style="width:200px"/></td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('nickName')}:</td>
			<td><input type="text" name="nickName" style="width:200px"/></td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('gender')}:</td>
			<td>
				<input type="radio" name="gender" value="MALE"/> ${i18n.getMessage('gender.male')}
				<input type="radio" name="gender" value="FEMALE"/> ${i18n.getMessage('gender.female')}
			</td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('dateOfBirth')}:</td>
			<td><input type="text" name="dateOfBirth" style="width:200px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].dateOfBirth, '${i18n.getMessage('format.date')}', this)"/></td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('address')}:</td>
			<td><input type="text" name="address" class="w200" /></td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('email')}:</td>
			<td><input type="text" name="email" class="w200" /></td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('phoneNumber')}:</td>
			<td><input type="text" name="phoneNumber" class="w200" /></td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('type')}:</td>
			<td>
				<select name="typeId" class="w200">
					<#list types as type>
						<option value="${(type.id)!}" <#if type.name="Normal">selected</#if>>${(type.name)!}</option>
					</#list>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('scholarship')}:</td>
			<td>
				<select name="scholarshipId" class="w200" onchange="showHideInfo(this)">
					<option></option>
					<#list scholarships as scholarship>
						<option value="${(scholarship.id)!}" style="<@formatOnScholarship scholarship/>">${(scholarship.name)!}</option>
					</#list>
				</select>
				<span class="pop-container" id="pop" style="display: none;"><div class="pop-container">
					<table cellspacing="4" align="center" cellpadding="0" width="340">
						<tr>
							<td class="name" width="100">${i18n.getMessage('school')}</td>
							<td>
								<select class="w020" onchange="showName(this)">
									<#list schoolNames as schoolName>
										<option value="${(schoolName.title)!}">${(schoolName.title)!}</option>
									</#list>
									<option value="other">Other:</option>
								</select>
								<input type="text" id="sname" name="school" class="w175" />
							</td>
						</tr>
						<tr>
							<td class="name">${i18n.getMessage('class')}</td>
							<td><input type="text" name="clazz" class="w200" /></td>
						</tr>
						<tr>
							<td class="name">${i18n.getMessage('studiedEnglishCenter')}</td>
							<td><input type="text" name="studiedEnglishCenter" class="w200" /></td>
						</tr>
						<tr>
							<td class="name" class="w200" name="schoolGradeId">${i18n.getMessage('grade')}</td>
							<td><select name="schoolGradeId" class="w200">
								<option></option>
								<#list schoolGrades as schoolGrade>
								<option value="${(schoolGrade.id)!}">${(schoolGrade.title)!}</option>
								</#list>
							</select></td>
						</tr>
					</table>					
				</div></span>
			</td>
		</tr>
		<tr>
			<td class="name"><@required/>Consulted Date:</td>
			<td><input type="text" name="consultedDate" value="${now?date}" style="width:200px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].consultedDate, '${i18n.getMessage('format.date')}', this)"/></td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('program')}:</td>
			<td>
				<select name="programId" style="width:204px">
					<option></option>
					<#list programs as program>
						<option value="${(program.id)!}">${(program.name)!}</option>
					</#list>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name">Test Date:</td>
			<td><input type="text" name="testDate" style="width:200px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].testDate, '${i18n.getMessage('format.date')}', this)"/></td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('testTime')}:</td>
			<td>
				<select name="placementShiftId" style="width:204px">
					<option></option>
					<#list shifts as shift>
						<option value="${(shift.id)!}">${(shift.startTime?time)!} - ${(shift.endTime?time)!}</option>
					</#list>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('Consultant')}:</td>
			<td>
				<select name="consultantId" style="width:204px">
					<option></option>
					<#list consultants as consultant>
						<option value="${(consultant.id)!}" <#if action.USER().id == consultant.id>selected</#if>>${(consultant.fullName)!}</option>
					</#list>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name" style="vertical-align:top">${i18n.getMessage('comment')}:</td>
			<td><textarea name="comment" style="width:350px;height:80px;"></textarea></td>
		</tr>
		<tr>
			<td class="name"></td>
			<td>
				<input type="submit" value="${i18n.getMessage('add')}" class="button_style"/> 
				<input type="reset" value="${i18n.getMessage('reset')}" class="button_style"/> 
			</td>
		</tr>
	</table>
</form>

<script>
	$('error').hide();
	showHideInfo = function(selector) {
		if (selector.value == "") {
			$("pop").style.display = "none";
		}
		else { $("pop").style.display = ""; }
	};
	
	showName = function(selector) {
		if (selector.value == "other") {
			$('sname').value = "";
		}
		else $('sname').value = selector.value;
	};
</script>